<?php


namespace App\Http\Controllers;

use App\Http\Resources\DeptCollection;
use App\Http\Resources\DictCollection;
use App\Http\Resources\JournalTypeCollection;
use App\Http\Resources\RoleCollection;
use App\Http\Resources\StockCollection;
use App\Http\Services\DictService;
use App\Http\Services\RoleService;
use App\Http\Services\JournalTypeService;
use App\Http\Services\StockService;
use App\Http\Traits\ApiReturn;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log;

class DictController extends BaseController
{
    use ApiReturn;
    protected $service;
    public function __construct(Request $request,DictService $dictService)
    {
        $this->service = $dictService;
        $this->request = $request;
        parent::__construct($request);
    }

    public function all()
    {
        $result = $this->service->all();
        return  $result;
    }

    public function index()
    {
        $result = $this->service->list($this->request->all());
        return  $this->succ(new DictCollection($result));
    }

    public function store(){
        $result = $this->service->store($this->request->all());
        return $this->succ($result);
    }

    public function options($type)
    {
        $result = $this->service->options($type);
        return  $this->succ($result);
    }

    public function update($id){
        $result = $this->service->store($this->request->all(),$id);
        return $this->succ($result);
    }


    public function detail($id){
        $result = $this->service->show($id);
        return $this->succ($result);

    }

    public function destroy($id){
        $result = $this->service->destroy($id);
        return $this->succ($result);
    }



}
